package com.huakang.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huakang.entity.Operation;
import com.huakang.service.OperationService;
import com.huakang.utils.OperationVo;
import com.huakang.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/operation")
public class OperationController {
    @Autowired
    OperationService operationService;
    @PostMapping("/insert")
    public ResultVo Insert(@RequestBody Operation operation){
        boolean b=operationService.insert(operation);
        if(b){
            return  ResultVo.success("预约成功");
        }
        return  ResultVo.fail("预约失败");
    }
    @GetMapping("/getAll")
    public ResultVo getAll(@RequestParam(defaultValue = "1")Integer pageNum , @RequestParam(defaultValue = "5")Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<OperationVo> list=operationService.getAll();
        PageInfo<OperationVo> pageInfo=new PageInfo<>(list);
        return  ResultVo.success("成功",pageInfo);
    }
}
